from compat import is_py2, builtin_str, str

def to_native_string(string, encoding='ascii'):
    if isinstance(string, builtin_str):
        out = string
    else:
        if is_py2:
            pass
        else:
            out = string.decode(encoding)

    return out

def unicode_is_ascii(u_string):
    try:
        u_string.encode('ascii')
        return True
    except UnicodeEncodeError:
        return False
